﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        var options = {
            id: "gridTable",
            url: "/DemoManage/Table/GetPageListJson",
            createUrl: "",
            updateUrl: "",
            removeUrl: "",
            sortName: "Id",
            sortOrder: "asc",
            modalName: "数据",
            columns: [
                { checkbox: true, visible: true },
                { field: 'id', title: '用户编号' },
                { field: 'realName', title: '用户姓名' },
                { field: 'mobile', title: '手机' },
                { field: 'email', title: '邮箱' },
                {
                    field: 'loginCount',
                    title: '登录次数',
                    footerFormatter: function (value) {
                        var sumBalance = 0;
                        for (var i in value) {
                            sumBalance += parseFloat(value[i].loginCount);
                        }
                        return "总次数：" + sumBalance;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
            ],
            onClickRow: function (row, element) {
                element[0].firstElementChild.firstElementChild.click();
            }
        };
        $.table.init(options);
    });
</script>
